<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body class="z1">
    <div id="box" class="z1">
      hello box
      <span class="z2">hello <i id="target">!!</i> </span>
    </div>
    <script>
      const target = document.getElementById("target");
      console.log(target.closest("span"));
      console.log(target.closest(".z1"));
    </script>
  </body>
</html>
